

package com.mt.repair.controller.repairManagement;

import org.springframework.security.access.prepost.PreAuthorize;
import com.mt.common.core.annotation.ApiPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.mt.common.core.web.base.PageDTO;
import com.mt.common.core.web.base.PageResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



import com.mt.repair.dto.repairManagement.FeedbackEditDto;
import com.mt.repair.entity.repairManagement.Feedback;
import com.mt.repair.service.repairManagement.FeedbackService;
											

@Api(tags = "维修评价")
@RestController
@RequestMapping("/api/repair/repairManagement/Feedback")
@CrossOrigin(allowCredentials = "true")
public class FeedbackController {
private static Logger logger = LoggerFactory.getLogger(FeedbackController.class);



																																				@Autowired private FeedbackService feedbackService;
	
	/**
	* 根据分页参数查询维修评价集合
	*
	* @param pageDTO 分页条件
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:view')")
	@ApiOperation("分页查询维修评价")
	@ApiPageParam
	@PostMapping("/findFeedbacks")
	public PageResultDTO findFeedbacks(@RequestBody PageDTO pageDTO){
		return this.feedbackService.findFeedbacks(pageDTO);
	}

	/**
	* 根据ID查询指定的维修评价
	*
	* @param feedbackId Id
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:view')")
	@ApiOperation("根据id查询维修评价")
	@ApiPageParam
	@PostMapping("/findFeedback")
	public Feedback findFeedback(@RequestParam Long feedbackId){
		return this.feedbackService.findFeedback(feedbackId);
	}

	/**
	* 根据ID查询指定的维修评价(包含外键名称)
	*
	* @param feedbackId Id
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:view')")
	@ApiOperation("根据ID查询指定的维修评价(包含外键名称)")
	@PostMapping("/findFeedbackForView")
	public Feedback findFeedbackForView(@RequestParam Long feedbackId){
		return this.feedbackService.findFeedbackWithForeignName(feedbackId);
	}

	/**
	* 根据ID查询指定的维修评价(包含维修评价和外键名称)
	*
	* @param feedbackId Id
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:view')")
	@ApiOperation("根据ID查询指定的维修评价(包含维修评价和外键名称)")
	@PostMapping("/findFeedbackForEdit")
	public FeedbackEditDto findFeedbackForEdit(@RequestParam Long feedbackId){
				FeedbackEditDto feedbackEditDto = new FeedbackEditDto();
		feedbackEditDto.setFeedback(this.feedbackService.findFeedbackWithForeignName(feedbackId));

		this.prepareFeedbackEditDto(feedbackEditDto);

		return feedbackEditDto;
	}

	/**
	* 根据ID查询指定的维修评价(只提取ID 和 Name)
	*
	* @param feedbackId Id
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:view')")
	@ApiOperation("根据ID查询指定的维修评价(只提取ID 和 Name)")
	@PostMapping("/findFeedbacksWithIdNameById")
	public Feedback findFeedbacksWithIdNameById(@RequestParam Long feedbackId){
	return this.feedbackService.findFeedbacksWithIdNameById(feedbackId);
	}

	/**
	* 根据名称查询维修评价集合(只提取ID 和 Name)
	*
	* @param feedbackName 名称
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:view')")
	@ApiOperation("根据名称查询维修评价集合(只提取ID 和 Name)")
	@PostMapping("/findFeedbacksWithIdNameByName")
	public List<Feedback> findFeedbacksWithIdNameByName(@RequestParam String feedbackName){
	return this.feedbackService.findFeedbacksWithIdNameByName(feedbackName);
	}


	/**
	* 创建新的维修评价
	*
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:add')")
	@ApiOperation("创建新的维修评价")
	@PostMapping("/createFeedback")
	public FeedbackEditDto createFeedback(){
				FeedbackEditDto feedbackEditDto = new FeedbackEditDto();
		feedbackEditDto.setFeedback(new Feedback());

		this.prepareFeedbackEditDto(feedbackEditDto);
		return feedbackEditDto;
	}

	private void prepareFeedbackEditDto(FeedbackEditDto feedbackEditDto){
																																			}

	/**
	* 新增保存维修评价
	*
	* @param feedback 实体对象
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:add')")
	@ApiOperation("新增保存维修评价")
	@PostMapping("/saveFeedback")
	public Feedback saveFeedback(@RequestBody Feedback feedback){
		return this.feedbackService.saveFeedback(feedback);
	}

	/**
	* 修改保存维修评价
	*
	* @param feedback 实体对象
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:update')")
	@ApiOperation("修改保存维修评价")
	@PostMapping("/updateFeedback")
	public Feedback updateFeedback(@RequestBody Feedback feedback){
		return this.feedbackService.updateFeedback(feedback);
	}

	/**
	* 根据ID删除维修评价
	*
	* @param feedbackId ID
	*/
	@PreAuthorize("hasAuthority('repair:repairManagement:Feedback:remove')")
	@ApiOperation("根据ID删除维修评价")
	@PostMapping("/deleteFeedback")
	public void deleteFeedback(@RequestParam Long feedbackId){
		this.feedbackService.deleteFeedback(feedbackId);
	}



}

